home *** CD-ROM | disk | FTP | other *** search
- //--------------------------------------------------------------------------------------------
- // Lighting Code
- //
- // by Philip McBride
- //
- //--------------------------------------------------------------------------------------------
-
-
- #include "GameControls.h"
- #include "extern.h"
- #include "lights.h"
-
- //--------------------------------------------------------------------------------------------
- // Create Lights
- //
- // make an ambient light as well as a number of point lights: from above both
- // forward and back (+/- z), in front (separate r, g, b) and in back (also
- // separate r, g, b)
- TQ3Status MyNewLights( DocumentPtr theDocument )
- {
- TQ3GroupObject lightGroup;
- TQ3LightObject light;
- TQ3PointLightData pointData;
- TQ3LightData ambientData;
-
- // make light group
- lightGroup = Q3LightGroup_New();
-
- // add ambient light
- ambientData.isOn = kQ3True;
- ambientData.brightness = 0.70;
- ambientData.color.r = 0.4;
- ambientData.color.g = 0.4;
- ambientData.color.b = 0.4;
-
- light = Q3AmbientLight_New(&ambientData);
- Q3Group_AddObject(lightGroup, light);
- Q3Object_Dispose(light);
-
- // light from above (both + and - z)
- pointData.lightData.isOn = kQ3True;
- pointData.lightData.brightness = 0.950;
- pointData.lightData.color.r = 1.0;
- pointData.lightData.color.g = 1.0;
- pointData.lightData.color.b = 1.0;
- pointData.location.x = 0.0;
- pointData.location.y = 1000.0;
- pointData.location.z = 1000.0;
- pointData.castsShadows = kQ3False;
- pointData.attenuation = kQ3AttenuationTypeNone;
-
- light = Q3PointLight_New(&pointData);
- Q3Group_AddObject(lightGroup, light);
- Q3Object_Dispose(light);
-
- pointData.location.z = -1000.0;
-
- light = Q3PointLight_New(&pointData);
- Q3Group_AddObject(lightGroup, light);
- Q3Object_Dispose(light);
-
- // light from front (r, g, b separate)
- pointData.lightData.brightness = 0.80;
- pointData.lightData.color.r = 1.0;
- pointData.lightData.color.g = 0.0;
- pointData.lightData.color.b = 0.0;
- pointData.location.x = -1000.0;
- pointData.location.y = 0.0;
- pointData.location.z = 1000.0;
-
- light = Q3PointLight_New(&pointData);
- Q3Group_AddObject(lightGroup, light);
- Q3Object_Dispose(light);
-
- pointData.lightData.color.r = 0.0;
- pointData.lightData.color.g = 1.0;
- pointData.lightData.color.b = 0.0;
- pointData.location.x = 1000.0;
-
- light = Q3PointLight_New(&pointData);
- Q3Group_AddObject(lightGroup, light);
- Q3Object_Dispose(light);
-
- pointData.lightData.color.r = 0.0;
- pointData.lightData.color.g = 0.0;
- pointData.lightData.color.b = 1.0;
-
- light = Q3PointLight_New(&pointData);
- Q3Group_AddObject(lightGroup, light);
- Q3Object_Dispose(light);
-
- // light from rear (r, g, b separate as above)
- pointData.lightData.color.r = 1.0;
- pointData.lightData.color.g = 0.0;
- pointData.lightData.color.b = 0.0;
- pointData.location.x = -1000.0;
- pointData.location.z = -1000.0;
-
- light = Q3PointLight_New(&pointData);
- Q3Group_AddObject(lightGroup, light);
- Q3Object_Dispose(light);
-
- pointData.lightData.color.r = 0.0;
- pointData.lightData.color.g = 1.0;
- pointData.lightData.color.b = 0.0;
- pointData.location.x = 1000.0;
-
- light = Q3PointLight_New(&pointData);
- Q3Group_AddObject(lightGroup, light);
- Q3Object_Dispose(light);
-
- pointData.lightData.color.r = 0.0;
- pointData.lightData.color.g = 0.0;
- pointData.lightData.color.b = 1.0;
-
- light = Q3PointLight_New(&pointData);
- Q3Group_AddObject(lightGroup, light);
- Q3Object_Dispose(light);
-
- // add light group to view and then dispose
- Q3View_SetLightGroup(theDocument->theView, lightGroup);
- Q3Object_Dispose(lightGroup);
-
- return(kQ3Success);
- }